package com.situ.day6.homework;

import java.lang.String;

// 1、如果一个类没有继承任何一个类，默认继承Object
public class Rect extends Object{
    private int width;
    private int height;

    // 2、如果不写任何的构造方法，系统默认提供一个无参的构造方法
    public Rect() {
        // 3、在子类的构造方法里面，首先要实例化父类对象，这里默认会有一个super()
        // new Object();
        // super();
        width = 1;
        height = 1;
    }

    public Rect(int width) {
        // super();
        this.width = width;
        this.height = width;
    }

    public Rect(int width, int height) {
        // super();
        this.width = width;
        this.height = height;
    }

    public int zhouChang() {
        return (width + height) * 2;
    }

    public int mianJi() {
        return width * height;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    @Override
    public String toString() {
        return "Rect{" +
                "width=" + width +
                ", height=" + height +
                '}';
    }
}
